
//% color="#cf1256" iconWidth=50 iconHeight=40
namespace vosktools{
    


  
    //% block="创建录音文件[filename] 时长[duration] 采样率[sample_rate] " blockType="command"
    //% filename.shadow="string" filename.defl="my_recording.wav" 
    //% duration.shadow="range" duration.params.min=0    duration.params.max=30    duration.defl=5 
    //% sample_rate.shadow="dropdown"   sample_rate.options="sample_rate" 

    export function voskinit_rp(parameter: any, block: any) {
        let filename=parameter.filename.code;
        let duration=parameter.duration.code;
        let sample_rate=parameter.sample_rate.code;
        
        Generator.addCode(`\nfrom audio_utils import record_audio, local_asr, AudioConfig \naudio_config = AudioConfig(filename=${filename}, duration=${duration}, sample_rate=${sample_rate}) \nrecord_audio(audio_config) \n`)

        
        
    }
    
    //% block="识别结果 " blockType="reporter"



    export function voskinit_rvboard(parameter: any, block: any) {


        Generator.addCode(`local_asr(audio_config.filename)`)

        
        
    }

    function replaceQuotationMarks(str:string){
            str=str.replace(/"/g, ""); //去除所有引号
            return str
    }


    
}
